package m.jclecai.com.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import m.jclecai.com.R;

/**
 * Created by hp on 2017/4/17.
 */

public class BQCDialog extends Dialog implements View.OnClickListener {
    private Context context;
    private BQCDialogListener listener;
    private View customView;
    private Button confirmBtn, cancleBtn;

    /**
     * @category 回调接口
     */
    public interface BQCDialogListener {
       void onClick(View view);
    }

    public BQCDialog(Context context) {
        super(context);
        this.context = context;
    }

    public BQCDialog(Context context, int themeResId) {
        super(context, themeResId);
        this.context = context;
    }

    public BQCDialog(Context context, int cancelable, BQCDialogListener listener) {
        super(context, cancelable);
        this.context = context;
        this.listener = listener;
        LayoutInflater inflater = LayoutInflater.from(context);
        customView = inflater.inflate(R.layout.dialog_add_bqc, null);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        setContentView(customView);
        confirmBtn = (Button) getCustomView().findViewById(R.id.dialog_confirm);
        cancleBtn = (Button) getCustomView().findViewById(R.id.dialog_cancel);

        TextView txt1 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_1);
        TextView txt2 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_2);
        TextView txt3 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_3);
        TextView txt4 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_4);
        TextView txt5 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_5);
        TextView txt6 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_6);
        TextView txt7 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_7);
        TextView txt8 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_8);
        TextView txt9 = (TextView) getCustomView().findViewById(
                R.id.jczq_bf_9);
        txt1.setOnClickListener(this);
        txt2.setOnClickListener(this);
        txt3.setOnClickListener(this);
        txt4.setOnClickListener(this);
        txt5.setOnClickListener(this);
        txt6.setOnClickListener(this);
        txt7.setOnClickListener(this);
        txt8.setOnClickListener(this);
        txt9.setOnClickListener(this);
        confirmBtn.setOnClickListener(this);
        cancleBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View arg0) {
        listener.onClick(arg0);
    }

    @Override
    public View findViewById(int id) {
        return super.findViewById(id);
    }

    public View getCustomView() {
        return customView;
    }
}
